package com.tcd.explore.service.impl;

import com.tcd.explore.pojo.SurveyLossInfo;
import com.tcd.explore.pojo.VerifyLossInfo;
import com.tcd.explore.mapper.VerifyLossInfoMapper;
import com.tcd.explore.service.VerifyLossInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tcd.outRisk.entity.CaseReportInfo;
import com.tcd.outRisk.entity.ClaimMainInfo;
import com.tcd.service.CaseReportInfoservice;
import com.tcd.service.Claimmainservice;
import com.tcd.explore.service.SurveyLossInfoService;
import com.tcd.service.WarrantyInfoservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 核损信息表 服务实现类
 * </p>
 *
 * @author Jarle
 * @since 2021-05-25
 */
@Service
public class VerifyLossInfoServiceImpl extends ServiceImpl<VerifyLossInfoMapper, VerifyLossInfo> implements VerifyLossInfoService {
    @Autowired
    VerifyLossInfoMapper verifyLossInfoMapper;
    @Autowired
    Claimmainservice claimmainservice;
    @Autowired
    WarrantyInfoservice warranty;
    @Autowired
    CaseReportInfoservice caseReportInfoservice;
    @Autowired
    SurveyLossInfoService surveyLossInfoservice;

    @Override
    public boolean verifysave(VerifyLossInfo verify) {
        boolean result = verifyLossInfoMapper.verifysave(verify);
        return result;
    }

    @Override
    public List<VerifyLossInfo> verifylist(String uid) {
        return verifyLossInfoMapper.verifylist(uid);
    }

    @Override
    public List<VerifyLossInfo> verifylisttow(String uid) {
        List<VerifyLossInfo> vlist = verifyLossInfoMapper.verifylist(uid);
        for (VerifyLossInfo v : vlist) {
            ClaimMainInfo claim = claimmainservice.Clainmainone(v.getClaimmainid() + "");
            SurveyLossInfo surveyLossInfo = surveyLossInfoservice.listsurvery(v.getClaimmainid() + "");
            CaseReportInfo caseReportInfo = caseReportInfoservice.caseReportone(claim.getCaseReportId() + "");
            claim.setWarray(warranty.getWarrantyInfo("", caseReportInfo.getCarnumber(), ""));
            v.setCliam(claim);
            v.setSurveyLossInfo(surveyLossInfo);
        }
        return vlist;
    }

    @Override
    public List<VerifyLossInfo> verifylistsplice(int page, int pagesize) {
        return verifyLossInfoMapper.verifylistsplice(page, pagesize);
    }

    @Override
    public boolean updateverify(String vid, String uid) {
        return verifyLossInfoMapper.updateverify(vid, uid);
    }
}
